<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt"  uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <title><spring:message code="head.clothGarment"></spring:message>-<spring:message code="login"></spring:message></title>
    <link href="${pageContext.request.contextPath }/phone/css/font/iconfont.css" rel="stylesheet" type="text/css" />
    <!--公共样式-->
    <link href="${pageContext.request.contextPath }/phone/css/public.css" rel="stylesheet" type="text/css" />
    <!--登录、注册、忘记密码三个页面样式-->
    <link href="${pageContext.request.contextPath }/phone/css/login1.css" rel="stylesheet" type="text/css" />
</head>
<body>
<!--头部 begin-->
<header class="page_topbar">
    <a href="javascript:history.go(-1);" class="back Hui-iconfont"></a>
    <a href="${pageContext.request.contextPath }/api/main/index" class="home Hui-iconfont">&#xe625;</a>
    <div class="title"><spring:message code="login.phone.title"></spring:message></div>
</header>
<!--头部 end-->
<div class="fast-load"><!--普通登陆-->
<img class="loginlogo" src="${pageContext.request.contextPath }/phone/img/logo.png" />
<h2 class="logintitle"><spring:message code="login.phone.login"></spring:message></h2>
<form id="signupForm" action="javascript:void(0)">
	<input type="hidden" name="language" value="1">
   	<input type="hidden" name="redirectUrl" value="${redirectUrl }"/>
    <div class="load-type-inp">
        <div class="phone">
            <label><spring:message code="login.phone.account"></spring:message>:</label>
            <input type="hidden" name="telphone1"/>
            <input type="text" id="telphone" name="telphone" autocomplete="off" maxlength="11" placeholder="<spring:message code="login.phone.pleaseAcc"></spring:message>" />
        </div>
		<input type="password" style="width:0;height:0;float:left;visibility:hidden"/>
		<input type="password" name="password1"  style="display:none"/>
        <div class="secret">
            <label><spring:message code="login.phone.password"></spring:message>:</label>
           	<input type="text" onfocus="this.type='password'" id="password" name="password" maxlength="15" autocomplete="off" placeholder="<spring:message code="login.phone.pleasePass"></spring:message>" />
        </div>
    </div>
    <div class="re-forg mt-0">
       <a class="pass" href="${pageContext.request.contextPath }/api/toPhonePage/forgetPassword"><spring:message code="login.forgotPassword"></spring:message>？</a>
       <div class="clearf"></div>
    </div>
    <div class="block-auto"><a class="end-next load-step" onclick="logsubmit();" href="javascript:void(0);"><spring:message code="login"></spring:message></a></div>
    <a href="${pageContext.request.contextPath }/api/main/index" class="youkelogin"><div><spring:message code="login.phone.visitor"></spring:message></div></a>
    <a class="res" href="${pageContext.request.contextPath }/api/toPhonePage/register"><div class="zhucelogin"><spring:message code="login.register"></spring:message></div></a>
</form>
</div>
<script type="text/javascript" src="${pageContext.request.contextPath }/web/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/h-ui/lib/layer/layer_mobile/layer.js"></script>
<script type="text/javascript">
function logsubmit(){
	var phone=$("#telphone").val();
	var passWord=$("#password").val();
	if(phone ==""){
		//layer.msg('<spring:message code="login.phoneCannotEmpty"></spring:message>',{icon:0,time:1000});
		layer.open({
		    content: '<spring:message code="login.phoneCannotEmpty"></spring:message>'
		    ,skin: 'msg'
		    ,time: 1 //1秒后自动关闭
		  });
		$("#telphone").focus();
		return false;
	}else{
		 var reg =/^1[3|4|5|7|8][0-9]\d{4,8}$/;
		 if (phone.length!=11||!(reg.test(phone))) {
			//layer.msg('<spring:message code="login.numberFormatError"></spring:message>',{icon:0,time:1000});
			layer.open({
			    content: '<spring:message code="login.numberFormatError"></spring:message>'
			    ,skin: 'msg'
			    ,time: 1 //1秒后自动关闭
			  });
			$("#telphone").focus();
			return false; 
		 }
	}
	if(passWord==""){
		//layer.msg('<spring:message code="login.passwordCannotEmpty"></spring:message>',{icon:0,time:1000});
		layer.open({
		    content: '<spring:message code="login.passwordCannotEmpty"></spring:message>'
		    ,skin: 'msg'
		    ,time: 1 //1秒后自动关闭
		  });
		$("#password").focus();
		return false;
	}
	$.ajax({
	    url: '${pageContext.request.contextPath}/api/logIn/landing',
	    type:'POST',
	    data:$("#signupForm").serialize(),
	    success: function(result){
	       if(result == 1){
    		   //layer.msg('<spring:message code="login.loginSuccess"></spring:message>',{icon:1,time:1000});
    		   layer.open({
    			    content: '<spring:message code="login.loginSuccess"></spring:message>'
    			    ,skin: 'msg'
    			    ,time: 1 //1秒后自动关闭
    			  });
    		   var url=$('input[name="redirectUrl"]').val();
 	    	  if(url!=null&&url!=""){
 	    		  location.href=url;
 	    	  }else{
 	    		 window.setTimeout("window.location.href='${pageContext.request.contextPath}/api/main/index'",2000);
 	    	  }
	       }else if(result == -2){
	    	   layer.open({
   			    content: '<spring:message code="login.memberstop"></spring:message>'
   			    ,skin: 'msg'
   			    ,time: 1 //1秒后自动关闭
   			  });
	    	   //layer.msg('<spring:message code="login.memberstop"></spring:message>',{icon:0,time:1000});
	       }else if(result == -1){
	    	   layer.open({
	   			    content: '<spring:message code="login.numberFormatError"></spring:message>'
	   			    ,skin: 'msg'
	   			    ,time: 1 //1秒后自动关闭
	   			  });
	    	   //layer.msg('<spring:message code="login.numberFormatError"></spring:message>',{icon:0,time:1000});
	       }else if(result == 0){
	    	   layer.open({
	   			    content: '<spring:message code="login.errorPassword"></spring:message>'
	   			    ,skin: 'msg'
	   			    ,time: 1 //1秒后自动关闭
	   			  });
	    	   //layer.msg('<spring:message code="login.errorPassword"></spring:message>',{icon:0,time:1000});
	       }else if(result == 2){
	    	   layer.open({
	   			    content: '<spring:message code="login.noexist"></spring:message>'
	   			    ,skin: 'msg'
	   			    ,time: 1 //1秒后自动关闭
	   			  });
	    	   //layer.msg('<spring:message code="login.noexist"></spring:message>',{icon:0,time:1000});
	       }else if(result == 3){
	    	   layer.open({
	   			    content: '<spring:message code="login.stop"></spring:message>'
	   			    ,skin: 'msg'
	   			    ,time: 1 //1秒后自动关闭
	   			  });
	    	   //layer.msg('<spring:message code="login.stop"></spring:message>',{icon:0,time:1000});
	       }else{
	    	   layer.open({
	   			    content: '<spring:message code="login.fail"></spring:message>'
	   			    ,skin: 'msg'
	   			    ,time: 1 //1秒后自动关闭
	   			  });
	    	   //layer.msg('<spring:message code="login.fail"></spring:message>',{icon:0,time:1000});
	       } 
    	}
	});
}
</script>
</body>
</html>